// React.forwardRef, 在父组件中通过ref拿到子组件的dom元素

import { useRef, forwardRef } from "react"

const Son = forwardRef((props, ref) => {
  return <input type="text" ref={ref} />
})

function App() {
  const sonRef = useRef(null)
  const showRef = () => {
    console.log(sonRef.current)
    sonRef.current.focus()

  }
  return (
    <div>
      <Son ref={sonRef} />
      <button onClick={showRef}>focus</button>
    </div>
  )
}
export default App